/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.sequence;

import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.swt.widgets.Composite;

import com.cea.papyrus.core.editor.EditorContextMenuProvider;
import com.cea.papyrus.core.editor.ModelManager;
import com.cea.papyrus.core.editor.abstracteditor.AbstractGraphicalPageWithFlyoutPalette;
import com.cea.papyrus.diagram.sequence.sedi.edit.SeDiEditPartFactory;
import com.cea.papyrus.diagram.sequence.sedi.editor.FontRegistry;
import com.cea.papyrus.diagram.sequence.sedi.editor.ImageLibrary;
import com.cea.papyrus.diagram.sequence.sedi.editor.ImageLibraryForUML2;
import com.cea.papyrus.diagram.sequence.sedi.editor.SeDiPaletteFactory;
import com.cea.papyrus.diagraminterchange2.di2.Diagram;

/**
 * An adapter to the sequence diagram editor SeDi.
 * 
 * @author frankd@ifi.uio.no
 */
public class SequenceDiagramEditor extends AbstractGraphicalPageWithFlyoutPalette {

	//Darpan
	public SequenceDiagramEditor() {
		
	}
	
    public SequenceDiagramEditor(Diagram diagram, ModelManager modelMngr) {
        super(diagram, modelMngr);
    }

    public SequenceDiagramEditor(Diagram diagram, ModelManager modelMngr,
            CommandStack commandStack, ActionRegistry actionRegistry) {
        super(diagram, modelMngr, commandStack, actionRegistry);
    }

    @Override
    public void dispose() {
        FontRegistry.releaseFont();
        super.dispose();
    }

    @Override
    protected PaletteRoot getPaletteRoot() {
        return SeDiPaletteFactory.createPaletteRoot(getImageLibrary());
    }

    /**
     * @see org.eclipse.gef.ui.parts.GraphicalEditor#createGraphicalViewer(org.eclipse.swt.widgets.Composite)
     */
    @Override
    protected void createGraphicalViewer(Composite parent) {
        super.createGraphicalViewer(parent);
    }

    @Override
    protected void configureGraphicalViewer() {
        super.configureGraphicalViewer();

        viewer = getGraphicalViewer();

        // Create and register the EditPartFactory
        viewer.setEditPartFactory(new SeDiEditPartFactory(this.modelMngr)); // modelMngr

        // configure the context menu provider
        // ContextMenuProvider provider = new SeDiContextMenuProvider(viewer,
        // getActionRegistry());
        // viewer.setContextMenu(provider);
        // getSite().registerContextMenu("no.uio.ifi.uml.sedi.context",
        // provider, viewer);
        cmProvider = new EditorContextMenuProvider(viewer, getActionRegistry(), modelMngr);
        super.configureContextMenuProvider();

        // Configure a specific font because the default font varies between
        // platforms
        viewer.getControl().setFont(FontRegistry.getFont());

    }

    protected ImageLibrary getImageLibrary() {
        return new ImageLibraryForUML2();
    }

}
